package com.scau.vo;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Admin entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "admin", catalog = "db_hairdressingpos")
public class Admin implements java.io.Serializable {

	// Fields

	private Integer id;
	private StoreInfo storeInfo;
	private Timestamp gmtCreate;
	private Timestamp gmtModified;
	private String name;
	private String password;
	private String phone;
	private String sex;
	private Integer type;
	private Set<SaleOrder> saleOrders = new HashSet<SaleOrder>(0);
	private Set<Payment> payments = new HashSet<Payment>(0);

	// Constructors

	/** default constructor */
	public Admin() {
	}

	/** minimal constructor */
	public Admin(Timestamp gmtCreate, String name, String password, Integer type) {
		this.gmtCreate = gmtCreate;
		this.name = name;
		this.password = password;
		this.type = type;
	}

	/** full constructor */
	public Admin(StoreInfo storeInfo, Timestamp gmtCreate,
			Timestamp gmtModified, String name, String password, String phone,
			String sex, Integer type, Set<SaleOrder> saleOrders,
			Set<Payment> payments) {
		this.storeInfo = storeInfo;
		this.gmtCreate = gmtCreate;
		this.gmtModified = gmtModified;
		this.name = name;
		this.password = password;
		this.phone = phone;
		this.sex = sex;
		this.type = type;
		this.saleOrders = saleOrders;
		this.payments = payments;
	}

	// Property accessors
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "storeId")
	public StoreInfo getStoreInfo() {
		return this.storeInfo;
	}

	public void setStoreInfo(StoreInfo storeInfo) {
		this.storeInfo = storeInfo;
	}

	@Column(name = "gmt_create", nullable = false, length = 19)
	public Timestamp getGmtCreate() {
		return this.gmtCreate;
	}

	public void setGmtCreate(Timestamp gmtCreate) {
		this.gmtCreate = gmtCreate;
	}

	@Column(name = "gmt_modified", length = 19)
	public Timestamp getGmtModified() {
		return this.gmtModified;
	}

	public void setGmtModified(Timestamp gmtModified) {
		this.gmtModified = gmtModified;
	}

	@Column(name = "name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "password", nullable = false)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "phone")
	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "sex")
	public String getSex() {
		return this.sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Column(name = "type", nullable = false)
	public Integer getType() {
		return this.type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "admin")
	public Set<SaleOrder> getSaleOrders() {
		return this.saleOrders;
	}

	public void setSaleOrders(Set<SaleOrder> saleOrders) {
		this.saleOrders = saleOrders;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "admin")
	public Set<Payment> getPayments() {
		return this.payments;
	}

	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}
	
	@Override
	public String toString() {
		return "{\"id\":" + id 
				+ ", \"gmtCreate\":" + "\"" +gmtCreate+ "\""
				+ ", \"gmtModified\":" + "\"" +gmtModified + "\""
				+ ", \"name\":" + "\"" +name + "\"" 
				+ ", \"password\":" + "\"" +password + "\"" 
				+ ", \"phone\":" + "\"" +phone + "\""
				+ ", \"sex\":" + "\"" +sex + "\""
				+ ", \"type\":" + "\"" + type + "\"" 
				+ "}";
	}

}